home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2003 June / macformat-130.iso / mac / Reviewed⁄Demos / Spearhead Demo / demota / pak1.pk3 / anim / motionblend.scr < prev    next >
Encoding:
Text File  |  2002-10-21  |  4.7 KB  |  211 lines

  1.  
  2.  
  3.  
  4. //=================================================
  5. //=================================================
  6. Start local.animbasename local.shootwhilemoving local.shootpct:
  7.     //***NOTE: The caller is responsible for setting self.position before calling this routine
  8.  
  9.     local.spawnedshootthread = 0
  10.     local.spawnedanimthread = 0
  11.     self.inreload = 0
  12.  
  13.     while(1)
  14.     {
  15.         if (self.movedir != (0 0 0))
  16.         {
  17.             //println "Motion blend with move dir: " self.movedir
  18.  
  19.             if (local.shootwhilemoving == 1)
  20.             {
  21.                 if (local.spawnedshootthread == 0)
  22.                 {
  23.                     thread ShootInMotion local.shootpct
  24.                     local.shootthread = parm.previousthread
  25.                     local.spawnedshootthread = 1
  26.                 }
  27.             }
  28.             else
  29.             {
  30.                 local.spawnedshootthread = 0
  31.             }
  32.  
  33.             if (local.spawnedanimthread == 0)
  34.             {
  35.                 thread AnimThread local.animbasename
  36.                 local.animthread = parm.previousthread
  37.                 local.spawnedanimthread = 1
  38.             }
  39.  
  40.             //waitexec anim/motionblend.scr::PlayAnim local.animbasename
  41.             waitframe
  42.         }
  43.         else
  44.         {
  45.             if (local.spawnedanimthread == 1)
  46.             {
  47.                 local.animthread delete
  48.                 local.spawnedanimthread = 0
  49.             }
  50.             
  51.             if (local.spawnedshootthread == 1)
  52.             {
  53.                 
  54.                 if (self.inreload == 1)
  55.                 {
  56.                     self setmotionanim (self.weapongroup + "_stand_alert_legs")
  57.                     //wait for the reload to finish
  58.                     while (self.inreload == 1)
  59.                     {
  60.                         waitframe
  61.                     }
  62.                 }
  63.  
  64.                 local.shootthread delete
  65.                 local.spawnedshootthread = 0
  66.             }
  67.  
  68.             //self setmotionanim (self.weapongroup + "_stand_alert")
  69.             //self waittill flaggedanimdone
  70.             waitexec anim/stand.scr
  71.         }
  72.     }
  73.  
  74.     //if (local.spawnedshootthread == 1)
  75.     //{
  76.     //    local.shootthread delete
  77.     //    local.spawnedshootthread = 0
  78.     //}
  79. end
  80.  
  81. //=================================================
  82. //=================================================
  83. PlayAnim local.animbasename:
  84.     if (self.movedir != (0 0 0))
  85.     {
  86.         local.dotvec = self.forwardvector * self.movedir
  87.         local.sidevec = self.leftvector * self.movedir
  88.         // (Boon) Divide by forward+side since it's the "correct" thing to do.  Might not make any noticeable improvement though.
  89.         local.forwardbackblend = abs(local.dotvec) / ( abs(local.dotvec) + abs(local.sidevec) )
  90.         local.sideblend = 1.0 - local.forwardbackblend
  91.     }
  92.     else
  93.     {
  94.         local.dotvec = 1.0
  95.         local.sidevec = 0.00
  96.         local.forwardbackblend = 1.0
  97.         local.sideblend = 0.00
  98.     }
  99.  
  100.     //sanity checks
  101.     if (local.sideblend < 0.00)
  102.     {
  103.         println "motionblend: sideblend is less than 0, how did that happen!?"
  104.         println "self.movedir " self.movedir
  105.         println "self.forward " self.forwardvector
  106.         local.sideblend = 0.00
  107.         local.forwardbackblend = 1.00
  108.     }
  109.  
  110.     if (local.sideblend > 1.0)
  111.     {
  112.         println "motionblend: sideblend is more than 1, how did that happen!?"
  113.         local.sideblend = 1.0
  114.         local.forwardbackblend = 0.00
  115.     }
  116.  
  117.     //println "Forward: " local.forwardbackblend " Side: " local.sideblend
  118.  
  119.     self.blendtime = 0.20
  120.  
  121.     if (local.dotvec >= 0.00)
  122.     {
  123.         //move forward
  124.         self setanim (local.animbasename + "forward") 0 local.forwardbackblend
  125.     }
  126.     else
  127.     {
  128.         self setanim (local.animbasename + "back") 0 local.forwardbackblend
  129.     }
  130.  
  131.     if (local.sidevec >= 0.00)
  132.     {
  133.         //move left
  134.         self setanim (local.animbasename + "left") 1 local.sideblend
  135.     }
  136.     else
  137.     {
  138.         //move right
  139.         self setanim (local.animbasename + "right") 1 local.sideblend
  140.     }
  141.  
  142.     wait 0.20
  143. end
  144.  
  145. //=================================================
  146. //=================================================
  147. ShootInMotion local.shootpct:
  148.     while (1)
  149.     {
  150.         // JBW - coverguy reload sets this when it runs to cover because of a reload
  151.         if ( self . forceReload == 1 )
  152.         {
  153.             self . roundsinclip = 0;
  154.             self . needreload = 1;            
  155.             self . forceReload = 0;
  156.         }
  157.  
  158.         if (self.needreload == 1)
  159.         {
  160.             waitexec anim/reload.scr::Reload 1
  161.         }
  162.         else
  163.         {
  164.             self.playedreloadanim = 0
  165.             self.playedrechamberanim = 0
  166.             self.inreload = 0
  167.         }
  168.  
  169.         waitexec anim/shoot.scr::CanShoot
  170.         if (self.canshoot == 1)
  171.         {
  172.             self setactionanim (self.weapongroup + "_aim") -60 60
  173.             self.needreload = 0
  174.             wait self.blendtime
  175.  
  176.             local.randnum = randomint 100
  177.             if (local.randnum < local.shootpct)
  178.             {
  179.                 waitexec anim/shoot.scr::CanShoot
  180.                 if (self.canshoot == 1)
  181.                 {
  182.                     self setactionanim (self.weapongroup + "_shoot") -60 60
  183.                     self.needreload = 1
  184.                     self waittill upperanimdone
  185.                 }
  186.                 else
  187.                 {
  188.                     //println "Not shooting while running"
  189.                     self endactionanim
  190.                     waitframe
  191.                 }
  192.             }
  193.         }
  194.         else
  195.         {
  196.             //println "Not shooting while running"
  197.             self endactionanim
  198.             waitframe
  199.         }
  200.     }
  201. end
  202.  
  203.  
  204. //=================================================
  205. //=================================================
  206. AnimThread local.animbasename:
  207.     while (1)
  208.     {
  209.         waitexec anim/motionblend.scr::PlayAnim local.animbasename
  210.     }
  211. end